package com.android.demo;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.webkit.WebView;
import android.widget.EditText;
import android.widget.LinearLayout;

public class TestWebView extends Activity implements OnClickListener{
	EditText et;
	/** Called when the activity is first created. */
	WebView webview;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		LinearLayout ll = new LinearLayout(this);
		ll.setOrientation(LinearLayout.VERTICAL);
		setContentView(ll);
		
		webview = new WebView(this);
		this.addContentView(webview, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
		
		testLoadRemoteImageView();
	}
	
	private void testLoadRemoteImageView(){
		webview.loadUrl("http://www.baidu.com");
	}
	
	private void testLoadLocalImage(){
//		webview.loadData(, mimeType, encoding);
		webview.setBackgroundColor(Color.BLACK);
		webview.loadUrl("file:///mnt/sdcard/sina_vdisk_kikilionforever@gmail.com/a.gif");
		
		//String str = 
			
		/*"<html lang=\"en\">"+
		"<head>"+
		  "<meta charset=\"UTF-8\">"+
		  "<title></title>"+
		  "<style type=\"text/css\">"+
			  ".img{border:1px solid #f60; background-color:#000; line-height:800px}"+
			  ".img img{width:100%; vertical-align:middle }"+
		  "</style>"+
		"</head>"+*/
		
				//"<img src=\"file:///mnt/sdcard/sina_vdisk_kikilionforever@gmail.com/a.gif\" alt=\"\" />";
				
		//"</html>";

		//webview.loadData(str, "text/html", "UTF-8");
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.add_btn:
			et.append("o_______o");
			break;
		case R.id.insert_btn:
			String str = "|-|";
			et.getText().insert(et.getSelectionStart(), str);
			break;
		}
		
	}
	
}